<template>
  <div
    class="build-wx-app-page"
  >
    <!-- <keep-alive> -->
    <el-container>
      <!-- 菜单  start -->
      <el-aside width="160px" class="menu-container">
        <div class="menu-title">
          <el-button type="text" icon="el-icon-arrow-left" class="btn-back" @click="back">返回后台&nbsp;&nbsp;&nbsp;
          </el-button>
        </div>
        <ul>
          <li
            v-for="item in menuOptions"
            :key="item.key"
            :class="{ active: menuName === item.key }"
            @click="handleMenu(item.key)"
          >
            <img
              :src="require('@/assets/icon/app/i-memu-' +
                item.key +
                (menuName === item.key ? '-active' : '') +
                '.png')
              "
              alt
              srcset
              class="icon"
            >
            <span>{{ item.name }}</span>
          </li>
        </ul>
      </el-aside>

      <!-- 菜单  end-->

      <el-container>
        <el-header class="flexRBC">
          <div class="active-app-box flexRCC">
            <span class="label">当前设计：</span>
            <el-dropdown>
              <span class="el-dropdown-link">
                商城小程序
                <i class="el-icon-arrow-down el-icon--right" />
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>商城小程序</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </el-header>

        <!-- 页面选择  -->
        <div v-if="menuName === 'page'" class="menu-content-box">
          <Page class="content" />
        </div>

        <!-- 导航模式 -->
        <div v-if="menuName === 'tabBar'" class="menu-content-box">
          <TabBar class="content" />
        </div>

        <!-- 启动模式 -->
        <div v-if="menuName === 'splashScreen'" class="menu-content-box">
          <SplashScreen class="content" />
        </div>

        <!--  主题模式-->
        <div v-if="menuName === 'theme'" class="menu-content-box">
          <Theme class="content" />
        </div>

        <!-- 菜单 主题模式 end-->

        <!-- 菜单 导航模式 end-->

        <!-- 菜单 启动模式 end-->
        <!-- 菜单 主题模式 start-->
        <!-- 菜单 主题模式 end-->
        <!-- 菜单 模板模式 start-->
        <!-- 菜单 模板模式 end-->
      </el-container>
    </el-container>
    <!-- </el-drawer> -->
  </div>
</template>

<script>
import Page from './page'
import TabBar from './tabBar'
import SplashScreen from './wxSplashScreen'
import Theme from './theme'

export default {
  components: {
    Page,
    TabBar,
    SplashScreen,
    Theme
  },
  data() {
    return {
      // 配置
      menuOptions: [
        {
          key: 'page',
          name: '页面'
        },
        {
          key: 'tabBar',
          name: '导航'
        },
        {
          key: 'splashScreen',
          name: '启动'
        },
        {
          key: 'theme',
          name: '主题'
        }
        // {
        //   key: "template",
        //   name: "模板",
        // },
      ],
      // 状态
      drawer: true,
      // 数据
      menuName: 'page'
    }
  },
  computed: {},
  watch: {},
  created() {
  },
  mounted() {
    // TODO 暂时解决全屏问题
    this.$nextTick(res => {
      document.getElementsByTagName('body')[0].classList.add('el-popup-parent--hidden')
    })
  },
  beforeDestroy() {
  },
  destroyed() {
    document.getElementsByTagName('body')[0].classList.remove('el-popup-parent--hidden')
  },
  methods: {
    /**
     * 数据组
     */
    /**
     * 按钮组
     */
    // 关闭
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then((_) => {
          done()
        })
        .catch((_) => {
        })
    },

    // 选择菜单
    handleMenu(menuName) {
      this.menuName = menuName
      // TODO 暂时解决全屏问题
      this.$nextTick(res => {
        document.getElementsByTagName('body')[0].classList.add('el-popup-parent--hidden')
      })
    },

    // 返回
    back() {
      this.$router.go(-1)
    }

    /**
     * 状态组
     */

    /**
     * 方法组
     */
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
/* 容器 */
.build-wx-app-page {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  margin: 0;
  z-index: 2000;
  background-color: #ededed;

  .el-container {
    display: flex;
    height: 100vh;
    //overflow-y: hidden;
    //min-width: 1500px;
  }

  // ::v-deep {
  //   .el-drawer.ttb {
  //     animation: none;
  //   }
  //   .el-drawer__body {
  //     background-color: #ededed;
  //     min-width: 1500px;
  //     .el-container {
  //       display: flex;
  //       height: 100vh;
  //     }
  //   }
  // }
  .main-container-title {
    margin-bottom: 10px;
    text-align: center;
    color: #303133;
    font-weight: bold;
  }
}

/* 菜单 */
.menu-container {
  padding: 0 15px;

  .menu-title {
    padding: 30px 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  li {
    display: flex;
    align-items: center;
    padding-left: 20px;
    margin-top: 10px;
    height: 48px;
    border-radius: 24px;
    font-size: 14px;
    cursor: pointer;

    .icon {
      width: 30px;
      height: 30px;
      margin-right: 10px;
    }
  }

  .active {
    background: $primary;
    color: #fff;
  }
}

/* 菜单内容 */
.menu-content-box {
  padding: 20px 20px 20px 0;
  flex: 1;

  .content {
    display: flex;
    flex-direction: row;
    flex: 1;
    flex-basis: auto;
    box-sizing: border-box;
    min-width: 0;
  }
}

/* 当前激活小程序 */
.active-app-box {
  width: 280px;
  height: 48px;
  background: #ffffff;
  border-radius: 10px;
  display: flex;

  .label {
    font-size: 14px;
  }

  .el-dropdown-link {
    cursor: pointer;
    color: $primary;
  }
}

// .el-header {
//   background-color: #fff;
//   box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
// }

.el-aside {
  // height: calc(100vh - 20px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  background-color: #fff;
  border-radius: 4px;
}

// .el-main {
//   height: calc(100vh - 80px);
//   box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
//   background-color: #fff;
//   border-radius: 4px;
// }
</style>
<style rel="stylesheet/scss" lang="scss">
//.el-popup-parent--hidden {
//  overflow: hidden;
//}
</style>
